home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / contour.arc / TEST.PAS < prev    next >
Pascal/Delphi Source File  |  1991-04-28  |  2KB  |  54 lines

  1. {$N+,E+}
  2. {test of contour plot routines
  3.  copyright 1988, Optimal Systems Laboratory, Plainfield, NJ}
  4. program test(input,output);
  5.  
  6. uses crt,video,c_defs,contour;
  7.  
  8. const
  9.   {setup for this particular piece of data}
  10.   x_size = 50;
  11.   y_size = 50;
  12.   num_contours = 30;
  13.  
  14. var
  15.   i,j : longint;
  16.   max, min : longint;
  17.   key : char;
  18.  
  19. begin
  20.   {allocate memory to data and contour arrays, this must always be the
  21.    first thing you do when using this package}
  22.   init_array;
  23.   {fill data array with sum of two Gaussians plus noise for this demo}
  24.   min:=1000000;
  25.   max:=-1000000;
  26.   for  i:= 0 to x_size-1 do
  27.     begin
  28.       for  j:= 0 to y_size-1 do
  29.         begin
  30.           data_array_pointer^[i]^[j]:=round(
  31.             30000.0*exp(-1*(sqr(i-35)+3.0*sqr(j-40))/450.0)+
  32.             30000.0*exp(-1*(3.0*sqr(i-10)+sqr(j-15))/450.0)+
  33.             random(1500));
  34.           if (min>data_array_pointer^[i]^[j]) then
  35.             min:=data_array_pointer^[i]^[j];
  36.           if (max<data_array_pointer^[i]^[j]) then
  37.             max:=data_array_pointer^[i]^[j];
  38.         end;
  39.     end;
  40.   {now make the contour levels}
  41.   for  i:= 0 to num_contours-1 do
  42.     contours^[i]:=min+i*(max-min)/(num_contours-1);
  43.   writeln('Filled data arrays, hit any key to continue.');
  44.   write('After plotting finished, hit any key to return to DOS');
  45.   key:=readkey;
  46.   {go to graphics mode}
  47.   init_graphics;
  48.   {plot the data}
  49.   contour_plot(x_size,y_size,num_contours);
  50.   key:=readkey;
  51.   {return to text screen}
  52.   close_graphics;
  53. end.
  54.